package com.ruoyi.baselibrary.infobaseindex.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.baselibrary.infobaseindex.domain.InfoBaseIndexDetail;
import com.ruoyi.baselibrary.infobaseindex.service.IInfoBaseIndexDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 基础库-指标库-指标详情Controller
 *
 * @author ruoyi
 * @date 2022-01-17
 */
@RestController
@RequestMapping("/infoBaseIndexDetail/infoBaseIndexDetail")
public class InfoBaseIndexDetailController extends BaseController {
    @Autowired
    private IInfoBaseIndexDetailService infoBaseIndexDetailService;

    /**
     * 查询基础库-指标库-指标详情列表
     */
    @PreAuthorize("@ss.hasPermi('infoBaseIndexDetail:infoBaseIndexDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(InfoBaseIndexDetail infoBaseIndexDetail) {
        startPage();
        List<InfoBaseIndexDetail> list = infoBaseIndexDetailService.selectInfoBaseIndexDetailList(infoBaseIndexDetail);
        return getDataTable(list);
    }

    /**
     * 导出基础库-指标库-指标详情列表
     */
    @PreAuthorize("@ss.hasPermi('infoBaseIndexDetail:infoBaseIndexDetail:export')")
    @Log(title = "基础库-指标库-指标详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoBaseIndexDetail infoBaseIndexDetail) {
        List<InfoBaseIndexDetail> list = infoBaseIndexDetailService.selectInfoBaseIndexDetailList(infoBaseIndexDetail);
        ExcelUtil<InfoBaseIndexDetail> util = new ExcelUtil<InfoBaseIndexDetail>(InfoBaseIndexDetail.class);
        util.exportExcel(response, list, "基础库-指标库-指标详情数据");
    }

    /**
     * 获取基础库-指标库-指标详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('infoBaseIndexDetail:infoBaseIndexDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(infoBaseIndexDetailService.selectInfoBaseIndexDetailById(id));
    }

    /**
     * 新增基础库-指标库-指标详情
     */
    @PreAuthorize("@ss.hasPermi('infoBaseIndexDetail:infoBaseIndexDetail:add')")
    @Log(title = "基础库-指标库-指标详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InfoBaseIndexDetail infoBaseIndexDetail) {
        return toAjax(infoBaseIndexDetailService.insertInfoBaseIndexDetail(infoBaseIndexDetail));
    }

    /**
     * 修改基础库-指标库-指标详情
     */
    @PreAuthorize("@ss.hasPermi('infoBaseIndexDetail:infoBaseIndexDetail:edit')")
    @Log(title = "基础库-指标库-指标详情", businessType = BusinessType.UPDATE)
    @PostMapping(value = "edit")
    public AjaxResult edit(@RequestBody InfoBaseIndexDetail infoBaseIndexDetail) {
        return toAjax(infoBaseIndexDetailService.updateInfoBaseIndexDetail(infoBaseIndexDetail));
    }

    /**
     * 删除基础库-指标库-指标详情
     */
    @PreAuthorize("@ss.hasPermi('infoBaseIndexDetail:infoBaseIndexDetail:remove')")
    @Log(title = "基础库-指标库-指标详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(infoBaseIndexDetailService.deleteInfoBaseIndexDetailByIds(ids));
    }
}
